cluster_covariates_vht <- vht_ml %>% 
	select(all_of(c("tc_id", covariates_only_vhts,
								covariates_all_healthworkers))) %>%
	group_by(tc_id) %>%
	dplyr::summarise(across(everything(), ~ mean(.x, na.rm = TRUE)))

covariate_frame <- cluster_covariates_vht[,c(covariates_only_vhts, covariates_all_healthworkers)]

covariate_imp <- mice(data = covariate_frame,m = 1,seed = 1234567)
covariate_imp <- complete(covariate_imp)

cluster_covariates_vht[,c(covariates_only_vhts, covariates_all_healthworkers)] <- covariate_imp[,c(covariates_only_vhts, covariates_all_healthworkers)]

rm(covariate_frame, covariate_imp)

# Merge with ml
ml <- merge(ml, cluster_covariates_vht, by = "tc_id", all.x = T)

# Merge with el
names(cluster_covariates_vht) <- paste0(names(cluster_covariates_vht), "_ml")

cluster_covariates_vht <- cluster_covariates_vht %>%
	mutate(tc_id = tc_id_ml) %>%
	select(-tc_id_ml)

el <- merge(el, cluster_covariates_vht, by = "tc_id", all.x = T)

rm(cluster_covariates_vht)
